//Done
public class Palindrome
{
   static String examples[] =
   { "racecar",
   "RACEcar", // uppercase equals lowercase
   "rotator",
   "rotor",
   "civic",
   "Red rum, sir, is murder!", // punctuation and spaces are neglected
   "Rats live on no evil star.",
   "Neil, a trap! Sid is part alien!",
   "Step on no pets.",
   "Dammit, I'm mad!",
   "Madam, I'm Adam.",
   "Madam, in Eden, I'm Adam.",
   "Rise to vote, sir.",
   "Never odd or even",
   "If I had a hi-fi",
   "Yo, banana boy!",
   "Do geese see God?",
   "No devil lived on.",
   "Ah, Satan sees Natasha.",
   "A dog, a panic in a pagoda",
   "Was it a cat I saw?",
   "Was it a car or a cat I saw?",
   "No lemons, no melon",
   "A dog, a plan, a canal, pagoda",
   "A man, a plan, a canal-- Panama!"
   };
   public static void main(String[] args)
   {
      //System.out.println(isPalindrome("Never odd or even"));
   }
   public static boolean isPalindrome(String x)
   {
      String palindrome = x.toLowerCase();
      boolean result = true;
      //One loop, 2 variables, 1 from left, 1 from right, skip space and punc.
      int left = 0;
      int right = palindrome.length()-1;
      
      while(left != right && left < right)
      {
         if(!Character.isLetter(palindrome.charAt(left)))
         {
            //System.out.println(left);
            left++;
         }
         else if(!Character.isLetter(palindrome.charAt(right)))
         {
            //System.out.println(right);
            right--;
         }
         else if(palindrome.charAt(left) == palindrome.charAt(right))
         {            
            left++;
            right--;
         }
         else
         {
            result = false;
            break;
         }
         //System.out.println("left: "+left+" right: "+right);
      }
     
      return result;
   }

}
